package pww.service.adminImpl;

import a.annotation.Component;
import a.annotation.Inject;
import dbUtil.SQLExecteException;
import pww.dao.AdministratorDao;
import pww.entity.Administrator;
import pww.entity.Student;
import pww.exception.LoginException;
import pww.exception.NofindException;
import pww.service.AdministratorService;

import java.sql.SQLException;

@Component
public class LoginAdminServiceImpl implements AdministratorService {
   @Inject("loginAdminDaoImpl")
    private AdministratorDao loginAdministrator;
    public Administrator isLogin(String account,String password) {
       Administrator login = loginAdministrator.isLogin("123","123");
        if (login==null){
            throw new LoginException("账号或者密码不正确");
        }
        return login;
    }

    @Override
    public void  updateStudent(Student student) {
        loginAdministrator.updateStudent(student);
    }
    @Override
    public void deleteStudent(Integer id) {
        loginAdministrator.deleteStudent(id);
    }
    @Override
    public Student select(Integer id) {
        Student select = loginAdministrator.select(id);
        if (select==null){
            throw new NofindException("没有这个学生信息");
        }
        return select;
    }
}
